package com.bps.zzant.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;

import com.bps.zzant.model.Customer;


public class CustomerDAOImpl implements CustomerDAO {
	@Autowired
	private SessionFactory sessionFactory;
	
	
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}


	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}


	public List<Customer> getCustomersByName(String customerName) {
		System.out.print("---------CustomerDAOImpl.getCustomersByName:" + customerName);
		List<Customer> customerList = getSessionFactory().getCurrentSession().createCriteria(Customer.class).add(Restrictions.like("customerName", customerName)).list();
		return customerList;
	}

}
